<!-- File: /app/views/language_experiences/index.ctp -->
<h1>
    Esperienze di 
    <?php echo $person['Person']['surname'].' '.$person['Person']['name'] ?>
</h1>
<table class="contentTable">
	<tr>
		<th>Lingua</th>
		<th>Lingua madre</th>
        <th>Listening</th>
		<th>Spoken int.</th>
        <th>Spoken prod.</th>
        <th>Writing</th>
        <th></th>
	</tr>

	<!-- Here is where we loop through our $posts array, printing out post info -->
        <!-- la variabile posts l'ho settata nel controller Post -->
	<?php foreach ($languageExperiences as $languageExperience) { ?>
	<tr>
		<td>
            <?php echo $languageExperience['Language']['name']; ?>
        </td>
        <td>
            <?php
            if($languageExperience['LanguageExperience']['mother_language'] == '1')
                echo 'Si';
            else
                echo 'No';
            ?>
        </td>
        <td>
            <?php echo $languageExperience['ListeningLevel']['name']; ?>
		</td>
        <td>
            <?php echo $languageExperience['SpokenInteractionLevel']['name']; ?>
		</td>
        <td>
            <?php echo $languageExperience['SpokenProductionLevel']['name']; ?>
		</td>
        <td>
            <?php echo $languageExperience['WritingLevel']['name']; ?>
		</td>
                <td>
                    <!-- uses the HtmlHelper to prompt the user with a JavaScript
                         confirmation dialog before they attempt to delete a post. -->
                    <?php echo $html->link('Modifica', array('action' => 'edit', $languageExperience['LanguageExperience']['id']))?>
                    <?php echo $html->link('Delete', array(
                                                'action' => 'delete',
                                                $languageExperience['LanguageExperience']['id'], $person['Person']['id']),
                                                null,
                                                'Procedendo si eliminerà definitivamente l\'esperienza. Continuare?' )?>

                </td>
	</tr>
	<?php } // foreach ?>

</table>
<div class="footer_buttons">
<?php echo $html->link('Aggiungi lingua',array('controller' => 'LanguageExperiences', 'action' => 'add', $person['Person']['id']), array('class' => 'button'))?>
<?php 
    if($from != 'edit_personal') {
        echo $html->link('Termina',array(
                            'controller' => 'curriculums', 
                            'action' => 'final_step', 
                            $person['Person']['id']), 
                            array('class' => 'button'));
    }
?>
<?php 
    
    if($from == 'edit_personal') {
        echo $html->link('Torna indietro',
                        array('controller' => 'people', 'action' => 'edit_personal'), 
                        array('class' => 'button'));
    }
    else {
        echo $html->link('Torna alla home',
                        array('controller' => 'People', 'action' => 'list_all'), 
                        array('class' => 'button'));
    }
    ?>
</div>